(function callee(){
    //noformat
    var FORM_WIDTH = 780, 
		oStore = new Ext.data.SimpleStore({
	        fields: ['abbr', 'state', 'nick'],
	        data: model.store.states
    	});
    //format
    
    view.ResidentialHistory = Ext.extend(Object, {
    
        constructor: function(){
            this.m_oApplicantHeader = new Ext.form.Label({
                html: "<div class='form-header'>Please give residential history (past 3 years, list current first)</div>"
            });
            constructFormElementsResidentialHistory.call(this);
            var aResidentialHistoryItems = [{
                items: [this.m_oAddress, this.m_oCity, this.m_oState, this.m_oZip]
            }, {
                items: [this.m_oDateMovedIn, this.m_oLandlord, this.m_oLandlordPhone, this.m_oRentPrice]
            },
			{
                items: [this.m_oReasonsForLiving]
            },
			{cls: "history-row",
                items: [this.m_oPreviousAddress, this.m_oPreviousRentPrice]
            },
			{
                items: [this.m_oPreviousLandlord, this.m_oPreviousLandlordPhone, 
						this.m_oPreviousDateMovedIn, this.m_oPreviousDateLeft]
            }];
            this.m_oApplicant = constructPanel(aResidentialHistoryItems);
            
            this.m_oBackingObject = new Ext.Panel({
                border: false
            });
            this.m_oBackingObject.add(this.m_oApplicantHeader);
            this.m_oBackingObject.add(this.m_oApplicant);
        }
    });
    
    function constructPanel(p_aItems){
        return new Ext.Panel({
            labelAlign: 'right',
            labelWidth: 100,
            border: false,
            items: [{
                border: false,
                defaults: {
                    layout: 'hbox',
					//cls: "history-row",
                    border: false,
                    defaults: {
                        anchor: '95%',
                        xtype: 'textfield',
						allowBlank:false,
                        plugins: [Ext.ux.FieldLabeler]
                    }
                },
                items: p_aItems
            }]
        });
    }
    
    function constructFormElementsResidentialHistory(){
        this.m_oAddress = {
            name: "address",
            fieldLabel: "Current Address",
            width: 320
        };
        this.m_oCity = {
            name: "city",
            fieldLabel: "City",
            labelWidth: 40
        };
        this.m_oState = {
            fieldLabel: 'State',
            name: "state",
            nameSpace: 'location',
            labelWidth: 50,
            store: oStore,
            displayField: 'state',
            typeAhead: true,
            mode: 'local',
            forceSelection: true,
            triggerAction: 'all',
            emptyText: 'Select a state...',
            selectOnFocus: true,
            xtype: 'combo',
            labelSeparator: '',
            width: 170,
            allowBlank: false
        };
        this.m_oZip = {
            name: "zip",
            fieldLabel: "Zip",
            labelWidth: 50,
            width: 100
        };
        
        this.m_oDateMovedIn = {
            fieldLabel: "Date moved in",
            name: "dateMovedIn",
            labelWidth: 100,
            width: 200,
			xtype: "datefield",
			maxValue: (new Date).clearTime() 
        }
        this.m_oReasonsForLiving = {
            name: "reasonsForLiving",
			labelWidth: 125,
            fieldLabel: "Reasons for leaving",
            width: 780,
			height: 40,
			xtype: "textarea"
        };
		this.m_oLandlord = {
			name: "landlord",
			labelWidth: 110,
			fieldLabel: "Current Landlord",
			width: 320
		};
		this.m_oLandlordPhone = {
			name: "landlordPhone",
			labelWidth: 50,
			fieldLabel: "Phone",
			emptyText: '(999) 999-9999',
			width: 150
		};
		this.m_oRentPrice = {
			name: "rentPrice",
			labelWidth: 50,
			fieldLabel: "Rent $",
			width: 110
		};
		//Previous Rent
		this.m_oPreviousAddress = {
            name: "addressPrevious",
            fieldLabel: "Previous Address",
            width: 670,
			labelWidth: 110
        };
		this.m_oPreviousLandlord = {
			name: "landlordPrevious",
			labelWidth: 110,
			fieldLabel: "Previous Landlord",
			width: 320
		};
		this.m_oPreviousLandlordPhone = {
			name: "landlordPhonePrevious",
			labelWidth: 50,
			fieldLabel: "Phone",
			emptyText: '(999) 999-9999',
			width: 140
		};
		this.m_oPreviousRentPrice = {
			name: "rentPricePrevious",
			labelWidth: 50,
			fieldLabel: "Rent $",
			width: 110
		};
		this.m_oPreviousDateMovedIn = {
			fieldLabel: 'Start Date',
	        name: 'previousDateMovedIn',
	        id: 'previousDateMovedIn',
	        vtype: 'daterange',
	        endDateField: 'previousDateLeft',
			xtype: "datefield",
			labelWidth: 65,
            width: 160,
			maxValue: (new Date).clearTime()
		};
		this.m_oPreviousDateLeft = {
			fieldLabel: 'End Date',
	        name: 'previousDateLeft',
	        id: 'previousDateLeft',
	        vtype: 'daterange',
	        startDateField: 'previousDateMovedIn',
			xtype: "datefield",
			labelWidth: 65,
            width: 160,
			maxValue: (new Date).clearTime()
		};
    }
})();
